# 自己实现WordCount功能
#coding:utf8

from pyspark import SparkContext, SparkConf

if __name__ == '__main__':

    conf = SparkConf().setMaster("local[*]").setAppName("myWordCount")
    sc = SparkContext(conf=conf)

    textFile = sc.textFile("../data/input/words.txt")

    print(textFile.flatMap(lambda data:data.split(" ")).map(lambda data : (data,1)).reduceByKey(lambda a,b:a+b).collect())
